package controller

import (
	"zzxq/common/codes"
	"zzxq/common/middleware/response"
	"zzxq/service"
	"zzxq/tools"

	"github.com/gin-gonic/gin"
)

type Sms struct{}

//发送登录短信
func (s *Sms) SendLoginCode(c *gin.Context) {
	phone, ok := c.GetPostForm("phone")
	if !ok {
		response.RespF(c, 3000, "参数异常")
		return
	}

	if phoneret := tools.VerifyMobileFormat(phone); phoneret {
		response.RespF(c, 3000, "手机号格式异常")
		return
	}

	smsobj := &service.Sms{}
	if err := smsobj.SLoginCode(phone); err {
		response.RespS(c, nil)
		return
	} else {
		response.RespF(c, codes.ERROR, "")
		return
	}
}
